<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                template="./../../../template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                >
    <f:metadata>
        <f:event type="preRenderView" listener="#{sessionManaged.validar_session('wfrmSubCategoria')}"/>
    </f:metadata>

    <ui:define name="main_content">

        <ui:include src="/web-pages/OTROS/HELP/wfrmHelp_mtto.xhtml">
            <ui:param name="toolBarWidth" value="750"/>
            <ui:param name="toolBarTitleWidth" value="700"/>
            <ui:param name="title" value="Sub Categor&iacute;a"/>
        </ui:include>

        <p:panel header="Informaci&oacute;n de SubCategor&iacute;a" style="width: 750px">

            <ui:include src="/web-pages/OTROS/wfrmMensaje.xhtml"/>

            <h:form id="SC">
                <h:panelGrid id="pSubCategoria" columns="2" cellpadding="3" style="width:inherit">
                    <h:outputText value="Categor&iacute;a" />
                    <h:selectOneMenu value="#{subCategoriaManaged.selectedSubCategoria.id_cat}" style="width: 340px">
                        <f:selectItems value="#{subCategoriaManaged.categorias}" var="su" itemLabel="#{su.nombre_cat}" itemValue="#{su.id_cat}" />
                    </h:selectOneMenu>

                    <h:outputLabel value="Sub Categor&iacute;a "/>
                    <p:inputText id="txtSubCategoria" value="#{subCategoriaManaged.selectedSubCategoria.nombre_su}" style="width: 330px"/>
                </h:panelGrid>

                <div align="center">
                    <br/>
                    <h:panelGrid id="pBotones" columns="3" cellpadding="5" style="width:inherit" >
                        <p:commandButton value="#{sms.guardar}" image="ui-icon ui-icon-check" onclick="cmdConfirm.show()" />
                        <p:commandButton value="#{sms.limpiar}" actionListener="#{limpiarManaged.limpiar}" update="SC:pSubCategoria grid:table" />
                        <p:confirmDialog message="#{sms.iAlmacenada}"  header="#{sms.guardar}" severity="alert" widgetVar="cmdConfirm">
                            <p:commandButton value="Si" actionListener="#{subCategoriaManaged.mantenimientoSubCategoria}" update="SC:pSubCategoria grid:table mensaje" oncomplete="cmdConfirm.hide()" />
                            <p:commandButton value="No" onclick="cmdConfirm.hide()"/>
                        </p:confirmDialog>
                    </h:panelGrid>
                    <br/>
                </div>
            </h:form>

            <h:form  id="grid">
                <p:panel header="Datos de SubCategor&iacute;a" style="width: inherit" >
                    <f:facet name="header">
                        <h:outputText value="Datos de SubCategor&iacute;a"/>
                        <p:commandButton image="ui-icon ui-icon-search" actionListener="#{subCategoriaManaged.fillGrid}" title="Buscar SubCategor&iacute;a" update="grid:table mensaje"/>
                    </f:facet>
                    <p:dataTable id="table" value="#{subCategoriaManaged.subCategorias}" var="row" rows="12"  selectionMode="single"
                                  selection="#{subCategoriaManaged.selectedSubCategoria}" paginator="true" paginatorPosition="bottom"
                                   emptyMessage="#{sms.TableEmptyMessage}" onRowSelectUpdate="SC:pSubCategoria">
                        <f:facet name="header" >
                            <h:outputText value="Lista de Sub Categor&iacute;as"/>
                        </f:facet>
                        <p:column filterBy="#{row.nombre_cat}" filterMatchMode="contains" headerText="Categor&iacute;a" sortBy="#{row.nombre_cat}">
                            <h:outputText value="#{row.nombre_cat}" />
                        </p:column>
                        <p:column filterBy="#{row.nombre_su}" filterMatchMode="contains" headerText="Sub-Categor&iacute;a"  sortBy="#{row.nombre_su}">
                            <h:outputText value="#{row.nombre_su}" />
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </h:form>


        </p:panel>
    </ui:define>

</ui:composition>
